<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

// Make sure no one attempts to run this script "directly"
if (!defined('DBC'))
	exit;

// Load the language file
require DBC_ROOT.'language/'.$admin_language.'/admin_plugin_merge_posts.php';

// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('DBC_PLUGIN_LOADED', 1);

// If the "Show text" button was clicked
if (isset($_POST['show_text']))
{
	// Make sure something was entered
	if (trim($_POST['text_to_show']) == '')
		message($lang_admin_plugin_merge_posts['No text']);

	$merge_timeout = intval($_POST['text_to_show']);
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$merge_timeout.'\' WHERE conf_name=\'o_merge_timeout\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());

	// Regenerate the config cache
	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require DBC_ROOT.'engine/cache.php';

	generate_config_cache();

	redirect(DBC_htmlspecialchars('admin_loader.php?plugin=AP_MergePosts.php'), $lang_admin_plugin_merge_posts['Plugin redirect']);

}
else
{
	// Display the admin navigation menu
	generate_admin_menu($plugin);

	if (!isset($DBC_config['o_merge_timeout']))
	{
		$result = $db->query('SELECT conf_value FROM '.$db->prefix.'config WHERE conf_name=\'o_merge_timeout\'') or error('Unable to fetch config info', __FILE__, __LINE__, $db->error());
		if (!$db->num_rows($result))
		{
			$db->query('INSERT INTO '.$db->prefix."config (conf_name, conf_value) VALUES('o_merge_timeout', '86400')") or error('Unable to insert into table config', __FILE__, __LINE__, $db->error());
			$merge_timeout = '86400';
		}
		else
			$merge_timeout = $db->result($result);

		if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
			require DBC_ROOT.'engine/cache.php';

		generate_config_cache();
	}
	else
		$merge_timeout = $DBC_config['o_merge_timeout'];

?>
	<div class="plugin blockform">


<table width="100%" height="38" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="28" class="bg_forum_title_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" class="bg_forum_title_center"><span class="cat_title"><?php echo $lang_admin_plugin_merge_posts['Plugin title'] ?></span></td>
<td align="center" width="28" class="bg_forum_title_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
</tr></table>



<table class="forum_adv_table"  width="100%" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" class="forum_adv_tleft" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" width="100%"><div class="forum_adv_c"><br/>
<div class="infldset">
			<div class="inbox">
				<?php echo $lang_admin_plugin_merge_posts['Explanation 1'] ?>
				<p><?php echo $lang_admin_plugin_merge_posts['Explanation 2'] ?></p>
			</div>
</div>
		<h2 class="block2"><span><?php echo $lang_admin_plugin_merge_posts['Form title'] ?></span></h2>
		<div class="box2">
			<form id="example" method="post" action="<?php echo DBC_htmlspecialchars($_SERVER['REQUEST_URI']) ?>&amp;foo=bar">
				<div class="inform">
						<div class="login_info"><?php echo $lang_admin_plugin_merge_posts['Legend text'] ?></div>
						<div class="infldset">
							<table class="aligntop" style="padding: 4px;" border="0" width="300" cellspacing="0" height="60">
								<tr>
									<td width="50%" align="left"><?php echo $lang_admin_plugin_merge_posts['Text to show'] ?></td>
									<td width="50%" valign="middle" align="left"><input type="text" name="text_to_show" style="margin-top: 4px;" size="5" class="input_text"  maxlength="5" tabindex="1" value="<?php echo DBC_htmlspecialchars($merge_timeout) ?>"/></td>
								</tr>
								<tr><td><input type="submit" class="fbutton" name="show_text" value="<?php echo $lang_admin_plugin_merge_posts['Show text button'] ?>" tabindex="2" /></td></tr>
							</table>
						</div>
				</div>
			</form>
<br/>
</td>
<td align="left" class="forum_adv_tright" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
</td></tr></table>
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
</tr></thead></table>
	</div>
<?php
}